<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <th:block th:include="include :: header('待派-信件工单')"/>
</head>
<body class="gray-bg">
<div class="container-div">
  <div class="row">
    <div class="col-sm-12 search-collapse">
      <form id="post-form">
        <div class="select-list">
          <ul>
            <li>
              联系电话：<input type="text" name="fromTel"/>
            </li>
            <li>
              内容类别：<input type="text" name="dcntAName"/>
            </li>
            <li>
              工单编号：<input type="text" name="workFormNo"/>
            </li>
            <li>
              来信人名：<input type="text" name="fromName"/>
            </li>
<!--            <li>-->
<!--              承办单位：<input type="text" name="dbo.frMDealDeptS(1,PkId,1)"/>-->
<!--            </li>-->
<!--            TODO 缺少根据承办单位查询-->
            <li>
              <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                      class="fa fa-search"></i>&nbsp;搜索</a>
              <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                      class="fa fa-refresh"></i>&nbsp;重置</a>
            </li>
          </ul>
        </div>
      </form>
    </div>

    <div class="btn-group-sm" id="toolbar" role="group">
        <a class="btn btn-success single disabled" onclick="$.operate.handleTab()">
          <i class="fa fa-reply"></i> 处理
        </a>
        <a class="btn btn-success single disabled" onclick="$.operate.editTab()">
          <i class="fa fa-edit"></i> 修改
        </a>
        <a class="btn btn-danger single disabled" onclick="$.operate.removeAll()">
          <i class="fa fa-remove"></i> 删除
        </a>
    </div>

    <div class="col-sm-12 select-table table-striped">
      <table id="bootstrap-table"></table>
    </div>
  </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
  var prefix = ctx + "system/mMailWF";

  $(function () {
    var options = {
      url: prefix + "/rManage/wfDraftListWllzJson",
      updateUrl: prefix + "/rManage/wfDraftCheck/{id}",
      uniqueId: "myPkVal",
      modalName: "待派信件工单",
      sortName:"pkId",
      sortOrder:"desc",
      fixedColumns: true,
      fixedNumber: 2,
      fixedRightNumber: 1,
      rowStyle: rowStyle,
      columns: [{
        checkbox: true
      },
        {field:'myPkVal',title:'pkId',hidden:true,visible:false},
        {field:'WorkFormNO',title:'工单编号',align:'center',halign:'center',sortable:true},
        {field:'SpareString',title:'信件来源',align:'center',halign:'center',sortable:true,
          formatter:function(value,row,index) {
            return value === '互联网+督查' ? '<span style="color:red;">'+value+'</span>' : value;
          }
        },
        {field:'SetProID',title:'性质',align:'center',sortable:true,formatter:function(value,row,index){return fmtWFormSort(value,row,index);}},
        {field:'FromTopic',title:'主题',align:'center',halign:'center',sortable:true},
        {field:'FromName',title:'来信人',align:'center',sortable:true},
        {field:'FromTel',title:'联系电话',align:'center',sortable:true},
        {field:'DCntAName',title:'内容类别',align:'center',sortable:true},
        {field:'fkDept',title:'承办单位',align:'center',halign:'center'},
        {field:'OpenX',title:'公开',align:'center',sortable:true,formatter:function(value,row,index){return fmtWFormOpen(value,row,index);}},
        {field:'FromTime',title:'来信时间',align:'center'},
        {field:'FlagString',title:'转办情况',align:'center',halign:'center',sortable:true},
        {field:'CrtStepName',title:'当前流程',align:'center'},
        // {field:'FromAccessory',title:'附件',align:'center',sortable:true,formatter:getFromAccessory},
        {field:'Mark',title:'是否紧急',align:'center',halign:'center',
          formatter:function(value,row,index){
            var mark=row.Mark;
            var rtn="否"
            if(mark==="1"){
              rtn="<span style='color:red;'>是</span>"
            }
            return rtn;
          }
        },
        // {
        //   title: '操作',
        //   align: 'center',
        //   formatter: function (value, row, index) {
        //     var actions = [];
        //     actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.handleTab('+row.myPkVal+')"><i class="fa fa-edit"></i>处理</a> ');
        //     return actions.join('');
        //   }
        {
          title: '操作',
          align: 'center',
          events: "operateEvents",
          formatter: function (value, row, index) {
            var actions = [];
            actions.push('<a id="id_row_handle" class="btn btn-success btn-xs" href="javascript:void(0)"><i class="fa fa-edit"></i>处理</a> ');
            return actions.join('');
          }
        }]
    };

    window.operateEvents = {
      "click #id_row_handle": function (e, value, row, index) {
        debugger
        $.operate.handleTab(row.myPkVal);
      }
    }
    $.table.init(options);
  });

  //判断有无附件
  function getFromAccessory(value,row,index){
    var mAccessoryUrl = row.FromAccessory;
    return mJudgeAccessory(mAccessoryUrl);
  }

  function mJudgeAccessory(FromAccessory){
    if(FromAccessory==null||typeof(FromAccessory)=="undefind"){
      return "无";
    }else{
      return "<img src='/../css/picture/mPicture/mAccessory.jpg'style='width:32px;heigth:32px'>";
    }
  }

  function rowStyle(index,row){
    var setProID = row.SetProID;
    var redStyle = {css: {'color':'#9400D3','font-weight':'bold'}};
    if(setProID==21){
      return redStyle;
    }
    return '';
  }

</script>
</body>
</html>